package demo.xlj.yuyi.studentapp.myadapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.util.MultiTypeDelegate;

import java.util.List;

import demo.xlj.yuyi.studentapp.R;
import demo.xlj.yuyi.studentapp.bean.RecyclerItemBean;

/**
 * 作者：项路俊 on 2018/3/12 0012
 * 邮箱：ThanksForCode@gmail.com
 * 介绍：
 */

public class TiMiAdapter extends BaseQuickAdapter<RecyclerItemBean,BaseViewHolder> {


    //0表示一般的样式，1表示选中的样式
    public TiMiAdapter(@Nullable List<RecyclerItemBean> data) {
        super(data);
        setMultiTypeDelegate(new MultiTypeDelegate<RecyclerItemBean>() {
            @Override
            protected int getItemType(RecyclerItemBean recyclerItemBean) {
                return recyclerItemBean.getType();
            }
        });
        getMultiTypeDelegate().registerItemType(0, R.layout.recycler_rect_text_item).registerItemType(1,R.layout.recycler_rext_text_tiem_2);
    }

    @Override
    protected void convert(BaseViewHolder helper, RecyclerItemBean item) {
        switch (helper.getItemViewType()){
            case 0:
                helper.setText(R.id.RectTextView_My_Test,item.getContent());
                helper.addOnClickListener(R.id.RectTextView_My_Test);
                break;

            case 1:
                helper.setText(R.id.RectTextView_My_Test_2,item.getContent());
                helper.addOnClickListener(R.id.RectTextView_My_Test_2);
                break;
        }

    }
}
